/*
 * Tools.h
 *
 *  Created on: 10/01/2011
 *      Author: Nenem
 */

#ifndef TOOLS_H_
#define TOOLS_H_

#include <stdlib.h>
#include <vector>
#include <string>
#include <iostream>
using namespace std;

#ifdef WINDOWS
    #include <direct.h>
    #define GetCurrentDir _getcwd
#else
    #include <unistd.h>
    #define GetCurrentDir getcwd
 #endif

string getPath();

class Point2D {
public:
	int x;
	int y;
	Point2D();
	Point2D(int x, int y);
	static Point2D midPoint(Point2D p1, Point2D p2);
	virtual ~Point2D();

	bool operator==(const Point2D& other) const;
	void operator=(const Point2D& other);
	Point2D operator+(const Point2D& other);
	Point2D operator-(const Point2D& other);

};

/*
 *  v1----------v2
 *   |          |
 *  v3----------v4
 */

class Rectangle{
	Point2D v1;
	Point2D v2;
	Point2D v3;
	Point2D v4;
public:
	Rectangle();
	Rectangle(int x1, int y1, int x2, int y2);
	Rectangle(Point2D v1, Point2D v4);
	bool contains(Point2D p);
	bool border(Point2D p);
	bool intersects(Rectangle rect);
	void print();
	static bool Interscetion(Rectangle r1, Rectangle r2);

	Point2D getV1(){
		return v1;
	}
	Point2D getV2(){
		return v2;
	}
	Point2D getV3(){
		return v3;
	}
	Point2D getV4(){
		return v4;
	}
};

template <class entity_type>
class Matrix{
private:
	entity_type *matrix;
	int rows;
	int columns;
public:
	Matrix();
	Matrix(int rows, int columns){
		this->rows = rows;
		this->columns = columns;

		matrix = (entity_type *)malloc(4*5*sizeof(entity_type));
	}
	virtual ~Matrix();
	void add(int i, int j, entity_type entity){
		matrix[i*columns + j] = entity;
	}
};

class Information{
public:
	Point2D point;
	int width;
	int height;
	Information(Point2D point, int width, int height){
		this->point = point;
		this->width = width;
		this->height = height;
	}
	Information(){}
	virtual ~Information(){}

};

#endif /* TOOLS_H_ */
